package Student;

import java.util.Scanner;

public class Adm_Student_View {
    // 显示操作菜单
    public static void displayMenu() {
        System.out.println("\n=========================================");
        System.out.println("            学生信息管理");
        System.out.println("=========================================");
        System.out.println("请选择操作：");
        System.out.println("1. 添加");
        System.out.println("2. 删除");
        System.out.println("3. 修改");
        System.out.println("4. 查询");
        System.out.println("5. 返回");
        System.out.println("=========================================");
    }


    public static void student() throws Exception {
        Scanner scanner = new Scanner(System.in);
        boolean running = true;

        while (running) {

            displayMenu();


            System.out.print("请输入您的选择: ");
            int choice = scanner.nextInt();

            scanner.nextLine();
            StudentDAO student = new Student();
            switch (choice) {
                case 1:
                    System.out.println("\n=========================================");
                    System.out.println("            添加学生信息");
                    System.out.println("=========================================");
                    System.out.println("请输入学生学号(8位)：");
                    String id1=scanner.nextLine();
                    System.out.println("请输入学生姓名：");
                    String name1=scanner.nextLine();
                    System.out.println("请输入学生电话号码(11位)：");
                    String phone1=scanner.nextLine();
                    System.out.println("请输入学生出生日期(yy-mm-dd)：");
                    String date1=scanner.nextLine();
                    student.insertStudent(id1, name1, phone1, date1);
                    break;
                case 2:
                    System.out.println("\n=========================================");
                    System.out.println("            删除学生信息");
                    System.out.println("=========================================");
                    student.getStudent();
                    System.out.println("请输入要删除的学生的学号：");
                    String id3=scanner.nextLine();
                    student.deleteStudent(id3);
                    break;
                case 3:
                    System.out.println("\n=========================================");
                    System.out.println("            更改学生信息");
                    System.out.println("=========================================");
                    student.getStudent();
                    System.out.println("请输入要更改的学生学号(8位)：");
                    String id2=scanner.nextLine();
                    System.out.println("请输入更新的学生姓名：");
                    String name2=scanner.nextLine();
                    System.out.println("请输入更新的学生电话(11位)：");
                    String phone2=scanner.nextLine();
                    System.out.println("请输入更新的学生出生日期(yy-mm-dd)：");
                    String date2 =scanner.nextLine();
                    student.updateStudent(id2, name2, phone2, date2);
                    break;
                case 4:
                    System.out.println("\n=========================================");
                    System.out.println("            查询全部学生信息");
                    System.out.println("=========================================");
                    student.getStudent();
                    break;
                case 5:
                    // 选择退出到主界面
                    System.out.println("\n=========================================");
                    System.out.println("正在返回主界面...");
                    System.out.println("=========================================");
                    running = false;
                    break;
                default:
                    System.out.println("\n输入无效，请重新选择！");
                    break;
            }
        }

    }
}
